package com.eastcom.mystope.common.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.eastcom.mystope.common.model.AbstractModel;
import com.eastcom.mystope.daemon.extern.db.config.Sql;

public interface ICommonDao {
    
    public <T extends AbstractModel> T save(T model);

    public <T extends AbstractModel> void saveOrUpdate(T model);
    
    public <T extends AbstractModel> void update(T model);
    
    public <T extends AbstractModel> void merge(T model);

    public <T extends AbstractModel, PK extends Serializable> void delete(Class<T> entityClass, PK id);

    public <T extends AbstractModel> void deleteObject(T model);

    public <T extends AbstractModel, PK extends Serializable> T get(Class<T> entityClass, PK id);
    
    public <T extends AbstractModel> int countAll(Class<T> entityClass);
    
    public <T extends AbstractModel> List<T> listAll(Class<T> entityClass);
    
    public <T extends AbstractModel> List<T> listAll(Class<T> entityClass, int pn);
    
    public <T extends AbstractModel> List<T> listAll(Class<T> entityClass, int pn, int pageSize);
    
    public boolean save(String modelName,Map<String, Object> model);
    public boolean update(String modelName,Map<String, Object> model);
    public boolean delete(String modelName,Map<String, Object> model);
    public List<Map<String, Object>> listAll(String modelName);
    public List<Map<String, Object>> listAll(String modelName, int pn);
    public List<Map<String, Object>> listAll(String modelName, int pn, int pageSize);
    
    public List querySQL(Sql sql);
    
}
